﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Net.Fan.SmallPig.BusinessRules;
using Net.Fan.SmallPig.Common;

public partial class User_ChangePwd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            labUserName.Text = this.User.Identity.Name;

        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string userName = this.User.Identity.Name;
        //if (txtOldPWD.Text.Length == 0)
        //{
        //    this.labMessage.Text = "原密码不能为空";
        //    return;
        //}
        if (txtNewPWD.Text.Trim().Length > 20 || txtNewPWD.Text.Length <= 1)
        {
            this.labMessage.Text = "错误,密码最短为2位,最长20位!";
            return;
        }
        //if (txtRepeatPWD.Text != txtNewPWD.Text)
        //{
        //    this.labMessage.Text = "错误,两遍输入的口令不一致!";
        //    return;
        //}
        if (UserBiz.ChangePassword(userName, txtOldPWD.Text, txtNewPWD.Text) == ErrorType.None)
        {
            labMessage.Text = "密码更新成功!";
            btnChange.Enabled = false;
        }
        else
        {
            labMessage.Text = "错误,请确认您的原始密码正确!";
        }
    }
}
